﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GeoUtils;

namespace GeoCoderParser
{
    public class GeoCoderResult
    {
        public List<Token> tokenList;
        public List<GeoEntityChain> geoEntityChainList;
        public List<GeoEntityChain> allCandGeoEntityChainList;
        public Dictionary<int, int> adminCode2PreCode;
        public Dictionary<int, string> adminCode2LocName;

        public string GetFullAddress(GeoEntity geoEntity)
        {
            if (geoEntity == null)
            {
                return "";
            }
            string strFullAddress = geoEntity.Name;

            if (adminCode2PreCode.ContainsKey(geoEntity.AdminCode) == false)
            {
                return strFullAddress;
            }

            int iAdminCode = adminCode2PreCode[geoEntity.AdminCode];
            while (true)
            {
                if (adminCode2LocName.ContainsKey(iAdminCode) == true)
                {
                    strFullAddress = adminCode2LocName[iAdminCode] + strFullAddress;
                }

                if (adminCode2PreCode.ContainsKey(iAdminCode) == false)
                {
                    break;
                }

                iAdminCode = adminCode2PreCode[iAdminCode];
            }
            return strFullAddress;
        }
    }
}
